<?xml version="1.0" encoding="UTF-8"?>
<!--
    JBoss, Home of Professional Open Source
    Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
    contributors by the @authors tag. See the copyright.txt in the
    distribution for a full listing of individual contributors.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   template="/WEB-INF/templates/default.xhtml">
   <ui:define name="content">
      <h1>Welcome to JBoss!</h1>

      <div>
         <p>You have successfully deployed a Java EE 6 Enterprise Application.</p>
      </div>

      <h:form id="reg">
         <h2>Member Registration</h2>
         <p>Enforces annotation-based constraints defined on the model class.</p>
         <h:panelGrid columns="3" columnClasses="titleCell">
            <h:outputLabel for="name" value="Name:"/>
            <h:inputText id="name" value="#{newMember.name}" />
            <h:message for="name" errorClass="invalid"/>

            <h:outputLabel for="email" value="Email:"/>
            <h:inputText id="email" value="#{newMember.email}"/>
            <h:message for="email" errorClass="invalid"/>

            <h:outputLabel for="phoneNumber" value="Phone #:"/>
            <h:inputText id="phoneNumber" value="#{newMember.phoneNumber}"/>
            <h:message for="phoneNumber" errorClass="invalid"/>
         </h:panelGrid>

         <p>
            <h:panelGrid columns="2">
               <h:commandButton id="register" action="#{memberController.register}" value="Register" styleClass="register"/>
               <h:messages styleClass="messages" errorClass="invalid" infoClass="valid" warnClass="warning"
                           globalOnly="true"/>
            </h:panelGrid>
         </p>
      </h:form>
      <h2>Members</h2>
      <h:panelGroup rendered="#{empty members}">
         <em>No registered members.</em>
      </h:panelGroup>
      <h:dataTable var="_member" value="#{members}" rendered="#{not empty members}" styleClass="simpletablestyle">
         <h:column>
            <f:facet name="header">Id</f:facet>
                #{_member.id}
            </h:column>
         <h:column>
            <f:facet name="header">Name</f:facet>
                #{_member.name}
            </h:column>
         <h:column>
            <f:facet name="header">Email</f:facet>
                #{_member.email}
            </h:column>
         <h:column>
            <f:facet name="header">Phone #</f:facet>
                #{_member.phoneNumber}
            </h:column>
         <h:column>
            <f:facet name="header">REST URL</f:facet>
            <a href="#{request.contextPath}/rest/members/#{_member.id}">/rest/members/#{_member.id}</a>
         </h:column>
         <f:facet name="footer">
            REST URL for all members: <a href="#{request.contextPath}/rest/members">/rest/members</a>
         </f:facet>
      </h:dataTable>
   </ui:define>
</ui:composition>
